#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
#define x first
#define y second
const int N = 1e5 + 10, M = 3 * N;
typedef pair<int, int> PII;
int n, m, k, q;
int h[N], e[M], ne[M], w[M], idx;
int dis[N];
int st[N];
priority_queue<PII, vector<PII>, greater<PII>>heap;
void add(int a, int b, int c)
{
	e[idx] = b;
	w[idx] = c;
	ne[idx] = h[a];
	h[a] = idx++;
}
void dijkstra()
{
	memset(dis, 0x3f, sizeof(dis));
	//cout << "---" << dis[3] << endl;
	dis[0] = 0;
	heap.push({ 0,0 });
	while (heap.size()) {
		PII t = heap.top();
		//cout << "t-->" << t.x << endl;
		heap.pop();
		int ver = t.y;
		int distance = t.x;
		if (st[ver])continue;
		st[ver] = 1;
		for (int i = h[ver]; ~i; i = ne[i]) {
			int j = e[i];
			//cout << "j--->" << j << endl;
			if (dis[j] > distance + w[i]) {
				dis[j] = distance + w[i];
				heap.push({ dis[j],j });
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b, c;
		cin >> a >> b >> c;
		add(a, b, c);
		add(b, a, c);
	}
	cin >> k;
	while (k--) {
		int c;
		cin >> c;
		add(0, c, 0);
	}
	dijkstra();
	cin >> q;
	while (q--) {
		int x;
		cin >> x;
		cout << dis[x] << endl;
	}
	return 0;
}